package com.wjh.controller;


import com.wjh.pojo.Flowerpot;
import com.wjh.pojo.FlowerpotCompany;
import com.wjh.pojo.FlowerpotType;
import com.wjh.service.FlowerTypeService;
import com.wjh.service.FlowerpotCompanyService;
import com.wjh.service.FlowerpotService;
import com.wjh.service.FlowerpotTypeService;
import com.wjh.utils.ResponseResult;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("flowerpot")
public class FlowerpotController {

    @Resource
    private FlowerpotCompanyService flowerpotCompanyService;

    @Resource
    private FlowerpotTypeService flowerpotTypeService;

    @Resource
    private FlowerpotService flowerpotService;

    @GetMapping("/like")
    public ResponseResult likeFlowerpot(String name){
        return flowerpotService.likeFlowerpot(name);
    }

    @GetMapping("/company/list")
    public ResponseResult queryCompanyList(Integer pageNum,Integer pageSize,String name){
        return flowerpotCompanyService.queryCompanyList(pageNum,pageSize,name);
    }

    @PostMapping("/company/add")
    public ResponseResult flowerpotCompanyAdd(@RequestBody FlowerpotCompany flowerpotCompany){
        return flowerpotCompanyService.flowerpotCompanyAdd(flowerpotCompany);
    }

    @GetMapping("/type/list")
    public ResponseResult flowerpotTypeList(Integer pageNum,Integer pageSize,String typeName,Integer type){
        return flowerpotTypeService.flowerpotTypeList(pageNum,pageSize,typeName,type);
    }

    @PostMapping("/type/add")
    public ResponseResult flowerpotTypeAdd(@RequestBody FlowerpotType flowerpotType){
        return flowerpotTypeService.flowerpotTypeAdd(flowerpotType);
    }

    /**
     * 查询所有花盆
     * @param pageNum
     * @param pageSize
     * @param type
     * @param flowerpotName
     * @return
     */
    @GetMapping("/list")
    public ResponseResult queryListFlowerpot(Integer pageNum,Integer pageSize,Integer type,String flowerpotName){
        return flowerpotService.queryListFlowerpot(pageNum,pageSize,type,flowerpotName);
    }

    /**
     * 添加花盆
     */
    @PostMapping("/add")
    public ResponseResult addFlowerpot(@RequestBody Flowerpot flowerpot){
        return flowerpotService.addFlowerpot(flowerpot);
    }

    /**
     * 删除花盆
     */
    @DeleteMapping("/{id}")
    public ResponseResult delByIds(@PathVariable("id") List<Integer> id){
        return flowerpotService.delByIds(id);
    }

    /**
     * 删除种类
     */
    @DeleteMapping("/type/{id}")
    public ResponseResult delByTypeIds(@PathVariable("id") List<Integer> id){
        return flowerpotTypeService.delByTypeIds(id);
    }

    /**
     * 删除花盆公司
     */
    @DeleteMapping("/company/{id}")
    public ResponseResult delCompanyByIds(@PathVariable("id") List<Integer> id){
        return flowerpotCompanyService.delCompanyByIds(id);
    }

    /**
     * 三级标签联查
     */
    @GetMapping("/query/list")
    public ResponseResult queryList(Integer companyId,Integer typeId){
        return flowerpotService.queryListByType(companyId,typeId);
    }
}
